package com.d3works.apps.businessproject.service;

import com.d3works.apps.account.db.Invoice;
import com.d3works.apps.account.db.InvoiceLine;
import com.d3works.apps.base.db.AppBusinessProject;
import com.d3works.apps.project.db.Project;
import com.d3works.apps.project.db.ProjectTask;
import com.d3works.apps.project.db.TaskTemplate;
import com.d3works.apps.project.service.ProjectTaskService;
import com.d3works.apps.sale.db.SaleOrderLine;
import com.d3works.apps.tool.QueryBuilder;
import com.d3works.auth.db.User;
import com.d3works.exception.D3worksException;
import com.google.inject.persist.Transactional;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

public interface ProjectTaskBusinessProjectService extends ProjectTaskService {

  ProjectTask create(SaleOrderLine saleOrderLine, Project project, User assignedTo)
      throws D3worksException;

  ProjectTask create(TaskTemplate template, Project project, LocalDateTime date, BigDecimal qty);

  ProjectTask updateDiscount(ProjectTask projectTask);

  ProjectTask compute(ProjectTask projectTask);

  List<InvoiceLine> createInvoiceLines(
      Invoice invoice, List<ProjectTask> projectTaskList, int priority) throws D3worksException;

  List<InvoiceLine> createInvoiceLine(Invoice invoice, ProjectTask projectTask, int priority)
      throws D3worksException;

  @Transactional(rollbackOn = {D3worksException.class, Exception.class})
  ProjectTask updateTaskFinancialInfo(ProjectTask projectTask) throws D3worksException;

  QueryBuilder<ProjectTask> getTaskInvoicingFilter();

  void taskInvoicing(Project project, AppBusinessProject appBusinessProject);

  @Transactional(rollbackOn = {D3worksException.class, Exception.class})
  ProjectTask updateTaskToInvoice(ProjectTask projectTask, AppBusinessProject appBusinessProject);

  ProjectTask resetProjectTaskValues(ProjectTask projectTask);
}
